﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;


namespace Phone
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private void Login_Load(object sender, EventArgs e)
        {
            textBox1.Text = Vars.sipUser;
            textBox2.Text = Vars.sipPassword;
            textBox3.Text = Vars.sipServerUri;
            textBox4.Text = Vars.sipProxyUri;
            textBox5.Text = Vars.sipSignUpUrl;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            // 用浏览器打开sipSignUpUrl
            ProcessStartInfo psi = new ProcessStartInfo(Vars.sipSignUpUrl);
            psi.UseShellExecute = true;
            Process.Start(psi);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Vars.sipUser = textBox1.Text;
            Vars.sipPassword = textBox2.Text;
            Vars.sipServerUri = textBox3.Text;
            Vars.sipProxyUri = textBox4.Text;
            Vars.sipSignUpUrl = textBox5.Text;

            // 重启程序
            Application.Restart();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Settings settings = new Settings();
            settings.Show();
            settings.Location = this.Location;
            this.Close();
        }

        private void Login_FormClosing(object sender, FormClosingEventArgs e)
        {
            if(Form.ActiveForm==this)Application.Exit();
        }
    }
}
